package com.tyut.mapper;

import com.github.pagehelper.Page;
import com.tyut.domain.User;
import com.tyut.dto.UserPageQueryDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    /**
     * 根据用户名查询
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    User getByUsername(String username);


    /**
     * 添加用户
     * @param user
     */
    @Insert("insert into user (id, username, password, email ,phone , role, create_time, image_url) " +
            "values (#{id},#{username},#{password},#{email},#{phone},#{role},#{createTime},#{imageUrl});")
    void add(User user);


    /**
     * 条件分页查询普通用户(1.分页展示普通用户 2.根据姓名条件查询用户)
     * @param userPageQueryDTO
     * @return
     */
    Page<User> pageQuery1(UserPageQueryDTO userPageQueryDTO);

    Page<User> pageQuery2(UserPageQueryDTO userPageQueryDTO);



    @Select("select * from user where id=#{id}")
    User getById(Integer id);



    void update(User user);
}
